package org.hairball;

import java.util.HashSet;
import java.util.Set;

public class Configuration implements ClassInclusionFilter {
    private String filename;
    private Format format;
    private String outputFile;
    private HashSet<AnalysisType> analysisTypes;
    private String[] packagesToInclude;

    //for testing only
    protected Configuration() {
        this(null, null, null, null);
    }

    public Configuration(
          String filename,
          Format format,
          String outputFile,
          HashSet<AnalysisType> analysisTypes,
          String... packagesToInclude) {
        this.filename = filename;
        this.format = format;
        this.outputFile = outputFile;
        this.analysisTypes = analysisTypes;
        this.packagesToInclude = packagesToInclude;
    }

    public Format getFormat() {
        return format;
    }

    public String getJarFile() {
        return this.filename;
    }

    public String getOutputFile() {
        return this.outputFile;
    }

    public Set<AnalysisType> getAnalysisTypes() {
        return this.analysisTypes;
    }

    public boolean shouldInclude(String fullyQualifiedClassName) {
        if (packagesToInclude.length > 0) {
            for (String packageToInclude : packagesToInclude) {
                if (fullyQualifiedClassName.startsWith(packageToInclude)) {
                    return true;
                }
            }
            return false;
        }
        return true;
    }
}
